package com.eleadmin.ocean.controller;

import com.eleadmin.common.core.web.*;
import com.eleadmin.common.core.annotation.OperationLog;
import com.eleadmin.damon.utils.results.PageResult2;
import com.eleadmin.ocean.entity.OceanBulkCargoProcess;
import com.eleadmin.ocean.service.OceanBulkCargoProcessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.apache.poi.ss.formula.functions.T;


/**
 *
 * 海运散货订单流程状态
 * @author : Doman
 * @date : 2023-11-14 14:03:28
 * @version ：1.0
 */

@Api(tags = "海运散货订单流程状态")
@RestController
@RequestMapping("/api/ocean/oceanBulkCargoProcess")
public class OceanBulkCargoProcessController extends BaseController {

    @Autowired
    private OceanBulkCargoProcessService oceanBulkCargoProcessService;

    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoProcess:list')")
    //@ApiOperation("分页查询海运散货订单流程状态")
    @GetMapping("/page")
    public JsonResult page(PageResult2<T> page, OceanBulkCargoProcess oceanBulkCargoProcess) throws Exception{
        return oceanBulkCargoProcessService.list(page, oceanBulkCargoProcess, getLoginUser());
    }

    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoProcess:list')")
    //@ApiOperation("查询全部海运散货订单流程状态")
    @GetMapping()
    public JsonResult list(OceanBulkCargoProcess oceanBulkCargoProcess){
        return oceanBulkCargoProcessService.list(oceanBulkCargoProcess, getLoginUser());
    }

    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoProcess:list')")
    //@ApiOperation("根据id查询海运散货订单流程状态")
    @GetMapping("/{id}")
    public JsonResult get(@PathVariable("id") String id) {
        return oceanBulkCargoProcessService.getById(id);
    }


    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoProcess:save')")
    @OperationLog
    @ApiOperation(value ="添加海运散货订单流程状态")
    @PostMapping()
    public JsonResult save(@RequestBody OceanBulkCargoProcess oceanBulkCargoProcess) {
        try {
            return oceanBulkCargoProcessService.save(oceanBulkCargoProcess, getLoginUser());
        } catch (Exception e) {
            return JsonResult.error(e.getMessage());
        }

    }

    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoProcess:update')")
    @OperationLog
    @ApiOperation(value ="修改海运散货订单流程状态")
    @PutMapping()
    public JsonResult update(@RequestBody OceanBulkCargoProcess oceanBulkCargoProcess) {
        try {
            return oceanBulkCargoProcessService.update(oceanBulkCargoProcess, getLoginUser());
        } catch (Exception e) {
            return JsonResult.error(e.getMessage());
        }
    }

    @PreAuthorize("hasAuthority('ocean:oceanBulkCargoProcess:remove')")
    @OperationLog
    @ApiOperation(value ="删除海运散货订单流程状态")
    @DeleteMapping("/{id}")
    public JsonResult remove(@PathVariable("id") String id) {
        try {
            return oceanBulkCargoProcessService.remove(id, getLoginUser());
        } catch (Exception e) {
            return JsonResult.error(e.getMessage());
        }
    }

}
